#ifndef GAMETD_TOWER_H
#define GAMETD_TOWER_H

#include "Timer.h"
#include "Vector2.h"
#include "Face.h"
#include "Animation.h"
#include "TowerType.h"
#include "../enemy/Enemy.h"
#include "../bullet/BulletType.h"

class Tower {
public:
    Tower();
    ~Tower() = default;
    void SetPosition(const Vector2 &position);
    const Vector2 &GetSize() const;
    const Vector2 &GetPosition() const;
    void OnUpdate(double delta);
    void OnRender(SDL_Renderer *renderer);

protected:
    Vector2 size;
    Animation animIdleUp;
    Animation animIdleDown;
    Animation animIdleLeft;
    Animation animIdleRight;
    Animation animFireUp;
    Animation animFireDown;
    Animation animFireLeft;
    Animation animFireRight;
    TowerType towerType = TowerType::Archer;
    double fireSpeed = 0;
    BulletType bulletType = BulletType::Arrow;

private:
    Timer timerFire;
    Vector2 position;
    bool canFire = true;
    Facing facing = Facing::Right;
    Animation *animCurrent = &animIdleRight;

private:
    void UpdateIdleAnimation();
    void UpdateFireAnimation();
    Enemy *FindTargetEnemy();
    void OnFire();
};


#endif //GAMETD_TOWER_H
